package com.ymtms.arrivalofgoods.dao;

import com.ymtms.arrivalofgoods.pojo.GoodsbillReceoptMain;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

public interface GoodsbillReceoptMainMapper {
    int deleteByPrimaryKey(Integer grmid);

    int insert(GoodsbillReceoptMain record);

    int insertSelective(GoodsbillReceoptMain record);

    GoodsbillReceoptMain selectByPrimaryKey(Integer grmid);

    int updateByPrimaryKeySelective(GoodsbillReceoptMain record);

    int updateByPrimaryKey(GoodsbillReceoptMain record);

    @Select("select*from goodsbill_receopt_main where goods_revert_bill_code=#{billCode}")
    GoodsbillReceoptMain queryReceiptByBillCode(String billCode);


    List<GoodsbillReceoptMain> queryAllGoodsbillByCondition(@Param("currentPage") Integer currentPage,
                                                            @Param("pageSize") Integer pageSize,
                                                            @Param("goodsbillReceoptMain") GoodsbillReceoptMain goodsbillReceoptMain
            , @Param("arriveBegin") Date arriveBegin, @Param("arriveEnd") Date arriveEnd, @Param("linkmanPhone") String linkmanPhone);

    @Select("select*from goodsbill_receopt_main where grmid in(select gid from check_goods_receive where status='未验收')")
    List<GoodsbillReceoptMain> findAllUnsettledReceipt();

    @Update("update goodsbill_receopt_main set if_balance='已结账',back_bill_state='已回执' where goods_revert_bill_code=#{billCode}")
    void updateGoodsbillReceipt(String billCode);


    void removeBatchByKey(Integer[] keys);
@Update("update goodsbill_receopt_main set execute=1 where grmid=#{grmid}")
    void updateExecuteByGrmid(Integer grmid);

    @Update("update goodsbill_receopt_main set execute=0 where goods_revert_bill_code=#{goodsRevertBillcode}")
    void updateExecuteToZero(String goodsRevertBillcode);
@Select("select*from goodsbill_receopt_main where goods_billpkid=#{gmid}")
    GoodsbillReceoptMain findReceiptMainByPkid(Integer gmid);


}